public class J05for {
    public static void main(String[] args) {
        //乱
        int count = 1;//a
        //...100
        while (count<=10){//b
            System.out.println("hello-"+count);
            System.out.println("abc");
            //....100
            count++;//c
        }
        //3个重要表达式，for解决这个问题
    }
}
class J05for2{
    public static void main(String[] args) {
        //for是格式化的while
        // i = 0
        for (int count=1;count<=10;count++){
            //1 2 3 ..... 9 10
            System.out.println(count);
            //...
        }
    }
}
class J05for3{
    public static void main(String[] args) {
        //1-100 逆向思维 不推荐
        for (int i = 100; i >= 1; i--) {
            //100 99 ....2 1
            System.out.println(101-i);
        }
    }
}

class J05forSum{
    //1-100 - 5050
    // (1+100)/2 *100
    //50.5*100 = 5050
    public static void main(String[] args) {
        //保存和
        int sum = 0;
        for (int i = 1; i < 101; i++) {
//            System.out.println(i);
            sum += i;
        }
        System.out.println("sum = " + sum);
    }
}











